<!-- 只有列表 -->
<template>
    <!-- 搜索框 -->
    <MyFilter :partParams="basicParams" @get-data="getData" @get-table-data="getTableData" @open-modal="openModal" />
    <!-- 列表 -->
    <MyTable ref="table" :partParams="tableParams" :tableInfo="tableInfo" />
    <!-- 新增弹框 -->
    <AddModal ref="modalRef" :partParams="basicParams" @refresh="refresh" />
  </template>
  
  <script lang="ts" setup>
  import MyFilter from './components/MyFilter.vue'
  import MyTable from './components/MyTable.vue'
  import AddModal from './components/AddModal.vue'
  import { defineProps, ref } from 'vue'
  import * as BasicApi from '../../api'
  import { useMessage } from '../../hooks/useMessage'
  
  //定义接收的props
  const props = defineProps({
    // 定义一个对象类型的 prop
    data: {
      type: Object,
      default: () => ({ groupName: '', jobType: '' })
    }
  })
  
  const basicParams = {
    groupName: props.data.groupName,
    jobType: props.data.jobType,
    operType: 'GetList'
  }
  
  const tableParams = ref()
  
  const table = ref()
  /** 查询列表 */
  const getData = async (query: any) => {
    tableParams.value = JSON.parse(JSON.stringify(query))
  }
  
  const tableInfo = ref([])
  // 获取表格信息
  const getTableData = (data: any) => {
    tableInfo.value = data
  }
  
  const message = useMessage()
  //新增
  const modalRef = ref()
  const openModal = async () => {
    modalRef.value.open()
  }
  
  const refresh = () => {
    tableParams.value = {
      ...basicParams,
      ...tableParams.value
    }
  }
  </script>
  